package com.spring.security.core.aop;

import java.lang.reflect.Method;

import javax.servlet.http.HttpServletRequest;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

@Aspect
@Component
public class CheckPermissionByToken {
	@Pointcut("@annotation(com.spring.security.core.annotation.CheckPermission)")
	public void checkPermission(){
	}
	
	@Around("checkPermission()")
	public Object aroundExec(ProceedingJoinPoint pjp) throws Throwable{
		MethodSignature ms=(MethodSignature) pjp.getSignature();
		Method method=ms.getMethod();
		Object[] os=pjp.getArgs();
//		for(Object str:os){
//			if(){
//				
//			}
//		}
		
		RequestAttributes ra = RequestContextHolder.getRequestAttributes();  
	    ServletRequestAttributes sra = (ServletRequestAttributes)ra;  
	    HttpServletRequest request = sra.getRequest();  
	    return null;
	}
}
